/**
  ******************************************************************************
  * File Name          : USART.h
  * Description        : This file provides code for the configuration
  *                      of the USART instances.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __usart_H
#define __usart_H
#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern UART_HandleTypeDef huart2;

/* USER CODE BEGIN Private defines */
extern const uint16_t ADI1787_ADC_MUTE_REG;
extern const uint16_t ADI1787_DAC_MUTE_REG;
extern const uint16_t ADI1787_FASTDSP_RUN;
extern const uint16_t ADI1787_BANK_CONTROL_REG;
extern const uint16_t ADI1787_ADC0_VALUE_REG;
extern const uint16_t ADI1787_ADC1_VALUE_REG;
extern const uint16_t ADI1787_ADC2_VALUE_REG;
extern const uint16_t ADI1787_ADC3_VALUE_REG;
extern const uint16_t ADI1787_ADC_DAC_POWER;
extern const uint16_t ADI1787_MBIAS_PGA_POWER;
extern const uint16_t ADI1787_POWER_CONTROL;
extern const uint16_t ADI1787_DAC0_ROUTE;
extern const uint16_t ADI1787_DAC1_ROUTE;
extern const uint16_t ADI1787_SPT0_CTRL;
extern const uint16_t ADI1787_MP_CTRL7;
extern const uint16_t ADI1787_MP_CTRL4;

extern const uint8_t ADC_MUTE[1];
extern const uint8_t ADC_UNMUTE[1];
extern const uint8_t VALUE_00[1];
extern const uint8_t VALUE_01[1];
extern const uint8_t VALUE_20[1];
extern const uint8_t VALUE_21[1];
extern const uint8_t VALUE_10[1];
extern const uint8_t VALUE_15[1];
extern const uint8_t VALUE_17[1];
extern const uint8_t VALUE_33[1];
extern const uint8_t VALUE_60[1];
extern const uint8_t ADC02_MUTE[1];
extern const uint8_t ADC13_MUTE[1];
extern const uint8_t ADC_POWER_OFF[1];
extern const uint8_t ADC_POWER_ON[1];
extern const uint8_t MBIAS_PGA_OFF[1];
extern const uint8_t MBIAS_PGA_ON[1];

extern const uint8_t ADC_Value_0[1];
extern const uint8_t ADC_Value_6[1];

extern const uint8_t BANK_A[1];
extern const uint8_t BANK_B[1];
extern const uint8_t BANK_C[1];

extern const uint8_t DAC_MUTE[1];
extern const uint8_t DAC_UNMUTE[1];

extern unsigned boot_flag;
extern uint8_t rxbuf[RX_LEN];
#define AT_A rxbuf[0]
#define AT_T rxbuf[1]
#define AT_PLUS rxbuf[2]
#define	AT_INS1 rxbuf[3]
#define	AT_INS2 rxbuf[4]
#define	AT_INS3 rxbuf[5]
#define	AT_INS4 rxbuf[6]
#define	AT_INS5 rxbuf[7]
#define	AT_INS6 rxbuf[8]
#define	AT_INS7 rxbuf[9]
#define	AT_INS8 rxbuf[10]
#define	AT_INS9 rxbuf[11]
#define AT_INS10 rxbuf[12]
#define AT_INS11 rxbuf[13]
#define AT_INS12 rxbuf[14]
#define AT_INS13 rxbuf[15]
#define AT_INS14 rxbuf[16]
#define AT_INS15 rxbuf[17]
#define AT_INS16 rxbuf[18]
#define AT_INS17 rxbuf[19]
#define AT_INS18 rxbuf[20]
#define AT_INS19 rxbuf[21]
#define AT_INS20 rxbuf[22]

// extern void SIGMA_WRITE_REGISTER_BLOCK(int devAddress,int address,int length, const uint8_t *pData);
// extern uint8_t Program_Eeprom(uint32_t Address, uint32_t Data);
// extern void reset_system(void);
// extern void off_flash_protection(void);

/* USER CODE END Private defines */

void MX_USART2_UART_Init(void);

/* USER CODE BEGIN Prototypes */

void switchBAVD(uint8_t para);
uint8_t DSP_ADC(uint8_t para1, uint8_t para2);
uint8_t DSP_DAC(uint8_t para1,uint8_t para2);
uint8_t DSP_PMDY(uint8_t para1, uint8_t para2);
uint8_t DSP_PLOAD(uint8_t para1,uint8_t para2);
uint8_t DSP_MODEA(void);
uint8_t DSP_MODEB(void);
uint8_t DSP_MODEC(void);
uint8_t DSP_GETR(int para1,int para2, uint8_t *pData);
uint8_t DSP_BT_POFF(void);
void UART_send_OK(void);
void UART_send_ERROR(void);
void HexToInt(uint8_t *s, int l, uint8_t *d);
void UartCommandHandle(void);

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif
#endif /*__ usart_H */

/**
  * @}
  */

/**
  * @}
  */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
